#include <xmlsec/xmltree.h>

void xuAddDoc(xmlNodePtr node, xmlDocPtr doc) {
  xmlAddChild(node, xmlDocCopyNode(xmlDocGetRootElement(doc), node->doc, 1));
}

xmlNodePtr xuNewDoc(const char *ns, const char *prefix, const char *root) {
  xmlDocPtr doc;
  xmlNodePtr n;
  xmlNsPtr nsp;

  doc = xmlNewDoc("1.0");
  n = xmlNewDocNode(doc, NULL, root, NULL);
  nsp = xmlNewNs(n, ns, prefix);
  xmlSetNs(n, nsp);
  xmlDocSetRootElement(doc, n);
  
  return n;
}
